|
|
|
|
|
|
|
The DrawMode property is the mode in which lines are drawn and shapes are filled. Two useful DrawModes are: |
|
|
|
|
| |
|
|
|
|
Draws in the normal drawing color, overwriting whatever is underneath. This is the default value for DrawMode. |
|
|
|
| | |
|
|
|
|
Inverts the colors over which you are drawing. This has the useful property that drawing the same thing twice using mode vbInvert restores the underlying image to its original form. |
|
|
|
|
|
|
|
|
|
|
You can use vbInvert mode and a form's MouseDown, MouseMove, and MouseUp event procedures to create rubber-band effects. In the MouseDown event procedure, set both end points of the rubber band line to the current mouse position. Then draw a line between those points using vbInvert mode. Initially, these are the same points, so you will not see much. |
|
|
|
|
|
|
|
|
In the MouseMove procedure, draw a line in vbInvert mode between the rubber band line's current end points. Drawing the same line twice in vbInvert drawing mode erases the line, so this erases the previous line between those points. Update the final endpoint coordinates for the line so that the line ends at the new mouse position. Finally, draw the new line in vbInvert mode. |
|
|
|
|
|
|
|
|
In the MouseUp event, redraw the most recent line once more to erase it. You can then take whatever action you need to process the line selected by the user. For example, you might draw the line again using drawing mode vbSrcCopy to make the line permanent. |
|
|
|
|
|
|
|
|
Example program RubrLine uses this technique to draw rubber-band lines. Click and drag the mouse to create a rubber-band line. When you release the mouse to finish the line, the program draws the line permanently on the form. |
|
|
|
|
|
|
|
|
The DrawStyle property determines the style in which lines are drawn. You can set DrawStyle as follows: |
|
|
|
|
| | | | | | | |
|
|
|
|
Draws alternating dashes and dots. |
|
|
|
| | |
|
|
|
|
Draws in a dash-dot-dot pattern. |
|
|
|
| | |
|
|
|
|
Draws lines invisibly. This is handy, for instance, if you want to fill a box without making its borders visible. |
|
|
|
| | |
|
|
|
|
Draws the line inside the position you specify. This is most noticeable if you draw a box with a large DrawWidth. In that case vbSolid draws the box's border half inside and half outside the box you specify, while vbInsideSolid draws the border entirely within the box. |
|
|
|
|
|
|
|